﻿Imports GT = Gadgeteer
Imports GTM = Gadgeteer.Modules
Imports Gadgeteer.Modules.GHIElectronics




Namespace TrafficLights
    Partial Public Class Program

        ' If you want to do something periodically, declare a GT.Timer by uncommenting the below line
        '   and then use the dropdown boxes at the top of this window to generate a Tick event handler.
        ' Dim WithEvents timer As GT.Timer = new GT.Timer(1000)  ' every second (1000ms)

        Dim WithEvents timer As GT.Timer = New GT.Timer(3000)  ' every three seconds
        Dim count As Integer = 0

        ' This is run when the mainboard is powered up or reset. 
        Public Sub ProgramStarted()
            '*******************************************************************************************
            ' Hardware modules added in the Program.gadgeteer designer view are used by typing 
            ' their name followed by a period, e.g.  button.  or  camera.
            '
            ' Many hardware modules generate useful events. To set up actions for those events, use the 
            ' left dropdown box at the top of this code editing window to choose a hardware module, then
            ' use the right dropdown box to choose the event - an event handler will be auto-generated.
            '*******************************************************************************************/

            ' Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started")            
            timer.Start()

        End Sub


        Private Sub timer_Tick(timer As Gadgeteer.Timer) Handles timer.Tick
            count = count + 1
            'First turn off all leds as they may be on from a previous timer tick
            led_Strip.TurnAllLedsOff()
            Select Case count


                Case 1   'Turn red led's on
                    led_Strip(5) = True
                    led_Strip(6) = True
                Case 2   'Turn red and amber led's on               
                    led_Strip(2) = True
                    led_Strip(3) = True
                    led_Strip(4) = True
                Case 3   'Turn green led's on
                    led_Strip(0) = True
                    led_Strip(1) = True
                    'Now reset, to go back to red (0)
                    count = 0
            End Select

        End Sub
    End Class
End Namespace